package com.wuxiaofan.product.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.product.entity.SkuInfo;
import com.wuxiaofan.product.entity.custom.SkuInfoCustom;
import com.wuxiaofan.product.mapper.SkuInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.product.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class SkuInfoService {
    @Autowired
    private SkuInfoMapper pmsSkuInfoMapper;
    @Resource
    private Idgenerator idgenerator;
    public SkuInfo findById(String id){
        return pmsSkuInfoMapper.selectById(id);
    }

    public SkuInfoCustom findCountByMap(Map paraMap){
        return pmsSkuInfoMapper.findCountByMap(paraMap);
    }

    public SkuInfoCustom findGroupByMap(Map paraMap){
        return pmsSkuInfoMapper.findGroupByMap(paraMap);
    }

    public List<SkuInfoCustom> findByMap(Map paraMap){
        return pmsSkuInfoMapper.findByMap(paraMap);
    }

    public Page<SkuInfoCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(pmsSkuInfoMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        pmsSkuInfoMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        pmsSkuInfoMapper.deleteById(id);
    }

    public SkuInfo save(SkuInfo pmsSkuInfo){
        pmsSkuInfo.setSkuId(idgenerator.getId());
        pmsSkuInfoMapper.insert(pmsSkuInfo);
        return pmsSkuInfo;
    }

}
